<template>
	<view class="container">
		<view v-if="!repairList.length">
			<view class="empty-state">暂无报修记录</view>
		</view>
	  <view class="repair-list" v-else>
		<view v-for="item in repairList" :key="item.id" class="repair-item">
		  <view class="repair-info">
			<text class="code">报修编号: {{ item.code }}</text>
			<text class="content">报修内容: {{ item.content }}</text>
			<text class="date">创建日期: {{ item.createDate }}</text>
			<text class="status">
			  状态: {{ getRepairStatus(item.repairStatus) }}
			</text>
		  </view>
		  <!-- <view v-if="item.image && item.image.length > 0" class="image-gallery"> -->
			<!-- <image v-for="img in item.image" :key="img" :src="img" class="repair-image" /> -->
		  <!-- </view> -->
		</view>
	  </view>
	</view>
  </template>
  
  <script setup lang="ts">
  import { getRepairList } from '../../services/repair';
  import { onLoad } from "@dcloudio/uni-app";
  import { RepairInfo } from '../../types/repair';
  import { ref } from 'vue';
  
  const repairList = ref<RepairInfo[]>([]);
  
  onLoad(async () => {
	const res = await getRepairList();
	repairList.value = res.data;
  });
  
  function getRepairStatus(status: number | null): string {
	switch (status) {
	  case 0:
		return '未派遣';
	  case 1:
		return '处理中';
	  case 2:
		return '已完成';
	  default:
		return '未知';
	}
  }
  </script>
  
  <style>
  .container {
	padding: 10px;
	background-color: #f9f9f9;
	height: 100vh;
	box-sizing: border-box;
  }
  
  .header {
	background-color: #007AFF;
	padding: 15px;
	text-align: center;
  }
  
  .title {
	font-size: 18px;
	color: #fff;
	font-weight: bold;
  }
  
  .repair-list {
	margin-top: 10px;
  }
  
  .repair-item {
	background-color: #fff;
	border-radius: 8px;
	margin-bottom: 10px;
	padding: 15px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  .repair-info {
	margin-bottom: 10px;
  }
  
  .code, .content, .date, .status {
	display: block;
	font-size: 14px;
	color: #333;
	margin-bottom: 5px;
  }
  
  .image-gallery {
	display: flex;
	flex-wrap: wrap;
  }
  
  .repair-image {
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 4px;
	margin-right: 5px;
	margin-bottom: 5px;
  }
  </style>
  